package com.example.producer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private ServletWebServerApplicationContext context;
    @RequestMapping("/hhh")
    public void say1(Exception e) throws Exception {
        System.out.println("1");
    }
    //    @RequestMapping("/hh")
//    public void say11(Exception e) throws Exception {
//        throw e;
//    }
    @RequestMapping("/hh")
    public void say(Exception e) throws Exception {
        System.out.println("1");
    }

    @RequestMapping("/getnamebyid")
    public String getNameById(Integer id) throws InterruptedException {
        System.out.println("=========   生产者方法执行了====================="+ LocalDateTime.now());
        Thread.sleep(1200);
        return "provider-name " + id +
                "server-port " + context.getWebServer().getPort();
    }

}
